using System;

namespace DataSync.Utilities
{
    /// <summary>
    /// Summary description for StringHelper.
    /// </summary>
    public class DateTimeHelper
    {
        public static DateTime StartDayOfWeek()
        {
            double offset = 0;
            switch (DateTime.Today.DayOfWeek)
            {
                case DayOfWeek.Monday:
                    offset = 0;
                    break;
                case DayOfWeek.Tuesday:
                    offset = -1;
                    break;
                case DayOfWeek.Wednesday:
                    offset = -2;
                    break;
                case DayOfWeek.Thursday:
                    offset = -3;
                    break;
                case DayOfWeek.Friday:
                    offset = -4;
                    break;
                case DayOfWeek.Saturday:
                    offset = -5;
                    break;
                case DayOfWeek.Sunday:
                    offset = -6;
                    break;
            }

            return DateTime.Today.AddDays(offset);
        }

	    public static int TimeToMinute(string strTime, int factor)
	    {	
            if(string.IsNullOrEmpty(strTime))
                return 0;

	        var timePart = strTime.Split(':');
	        return ((factor * Int32.Parse(timePart[0]) * 60) + Int32.Parse(timePart[1]));
	    }

    }
}